package com.mlf.prototype.spring;

import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Component;

// 使用Scoped Proxy的原型Bean
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE, proxyMode = ScopedProxyMode.TARGET_CLASS)
public class PrototypeBeanWithProxy {
    private static int instanceCount = 0;
    private final int instanceId;
    
    public PrototypeBeanWithProxy() {
        instanceId = ++instanceCount;
    }
    
    public String getIdentity() {
        return "Prototype with proxy instance #" + instanceId;
    }
}
